<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Http\Resources\SchoolDetail;


class School extends Model
{
    
    const IFSHOW_YES = 2;
    const IFSHOW_NO = 1;
    const IFSHOW_YES_STRING = '正常';
    const IFSHOW_NO_STRING = '禁用';
    
    protected $table = 'school';
    protected $primaryKey = 'id';

    // 定义关联关系
    public function dorm()
    {
        return $this->hasMany(Dorm::class, 'sid', 'id');
    }
    
    
    public static function getSchoolInfoByID($id)
    {
        $result = School::find($id);
        if ($result) {
            return new SchoolDetail($result);
        } else {
            return false;
        }
    }
   
}